package com.fulihui.usercore.common.util;

import org.near.servicesupport.error.ServiceError;

/**
 * @author Willard.Hu on 2016/11/7 0007.
 */
public class Errors {

    private static final int USER_ERRCODE_START = 1000;

    private static final int USER_ADDRESS_ERRCODE_START = 1100;

    private static final int USER_TAG_ERRCODE_START = 1200;

    private static final int USER_VCODE_ERRCODE_START = 1300;

    private static final int USER_MERCHANT_ERRCODE_START = 1400;

    /**
     * 用户服务错误枚举
     */
    public enum User implements ServiceError {
        NOT_FOUND_USER(1, "没有找到用户"),

        PASSWORD_FAILED(2, "用户密码错误"),

        USER_MODIFY_FAILED(3, "用户信息修改错误"),

        USER_HAS_REGISTERED(4, "用户已注册"),

        USER_HAS_BINDING_WECHAT(5, "用户已绑定微信"),

        WECHAT_HAS_BINDING_USER(6, "微信已被其他用户绑定"),

        MODIFY_PASSWD_VALID_VCODE_FAILED(8, "修改密码，验证码错误"),

        MODIFY_PASSWD_VALID_OLDPASSWD_FAILED(9, "修改密码，旧密码错误"),

        FORBID_USER_STATE(10, "用户已被禁用"),

        LOGIN_HAS_BINDING(11, "该手机号已被绑定，请更换手机号！"),;
        int    errcode;
        String errmsg;

        User(int errcode, String errmsg) {
            this.errcode = USER_ERRCODE_START + errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    /**
     * 用户地址服务错误枚举
     */
    public enum UserAddress implements ServiceError {

        SAVE_FAILED(1, "用户地址保存失败"),

        DEL_FAILED(2, "用户地址删除失败"),

        ADDRESS_SIZE_OVER_LIMIT(3, "用户地址数量超出限制");

        int    errcode;
        String errmsg;

        UserAddress(int errcode, String errmsg) {
            this.errcode = USER_ADDRESS_ERRCODE_START + errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    /**
     * 用户认证信息服务错误枚举
     */
    public enum UserAddressExt implements ServiceError {

        SAVE_FAILED(1, "用户认证信息保存失败"),

        UPDATE_FAILED(1, "修改用户认证信息失败"),

        DEL_FAILED(2, "用户认证信息删除失败");

        int    errcode;
        String errmsg;

        UserAddressExt(int errcode, String errmsg) {
            this.errcode = USER_ADDRESS_ERRCODE_START + errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    /**
     * 商户服务错误枚举
     */
    public enum Merchant implements ServiceError {
        THIRD_MERCHANT_OPERATE_ERROR(1, "第三方商户操作失败"),

        COOPERATION_INFO_OPERATE_ERROR(2, "合作方式操作失败"),

        MERCHANT_OPERATE_ERROR(3, "商户操作失败"),

        COOPERATION_TIME_ERROR(4, "合作方式时间错误"),

        MERCHANT_NAME_HAS_EXISTS(5, "商户名称已存在"),;

        int    errcode;
        String errmsg;

        Merchant(int errcode, String errmsg) {
            this.errcode = USER_MERCHANT_ERRCODE_START + errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    /**
     * 用户标签服务错误枚举
     */
    public enum UserTags implements ServiceError {
        TAG_SAVE_FAILED(1, "标签保存失败"),

        TAG_DELETE_FAILED(2, "标签删除失败"),;

        int    errcode;
        String errmsg;

        UserTags(int errcode, String errmsg) {
            this.errcode = USER_TAG_ERRCODE_START + errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

    /**
     * 验证码服务错误枚举
     */
    public enum VCode implements ServiceError {
        CANT_REPEAT_IN_TIME(1, "在指定时间段内不能重复尝试"),

        VCODE_VALIDATION_FAILS(2, "验证码验证失败"),;

        int    errcode;
        String errmsg;

        VCode(int errcode, String errmsg) {
            this.errcode = USER_VCODE_ERRCODE_START + errcode;
            this.errmsg = errmsg;
        }

        @Override
        public int getErrcode() {
            return errcode;
        }

        @Override
        public String getErrmsg() {
            return errmsg;
        }
    }

}
